package com.madou.yy.football;

import com.madou.yy.football.obstacle.Goalkeeper;
import com.madou.yy.football.obstacle.Shitou;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;

public class Football {
    int baseX = 130;
    int baseY = 30;

    BackgroundPanel jPanel;

    public Football() throws IOException {
        // - 如何创建JFrame窗口？
        JFrame jFrame = new JFrame("2022——世界杯大赛小游戏");
        jFrame.setVisible(true);//设置窗口可见
        jFrame.pack();// 立即显示出来
        jFrame.setSize(new Dimension(800,650));
        // - 如何关闭窗口？——退出窗口
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setLayout(new BorderLayout());

        InfoPanel infoPanel = new InfoPanel();
        infoPanel.setPreferredSize(new Dimension(-1,60));
        jFrame.add(infoPanel,BorderLayout.SOUTH);

        //  - 如何创建JPanel面板？
        jPanel = new BackgroundPanel(infoPanel);
        jFrame.add(jPanel,BorderLayout.CENTER);

        Ball ball = new Ball();
        jPanel.add(ball);
        jPanel.setBall(ball);

        Goalkeeper goalkeeper = new Goalkeeper(jPanel);
        jPanel.add(goalkeeper);

        Shitou shitou = new Shitou(jPanel);
        jPanel.add(shitou);
        jPanel.start();
        jFrame.repaint();
    }

    public static void main(String[] args) throws IOException {
        new Football();
    }


}
